Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jQuery missing issues for newer Sidekiq versions #181

Merged
merged 3 commits into from
Apr 13, 2022
Merged

Fix jQuery missing issues for newer Sidekiq versions #181

merged 3 commits into from
Apr 13, 2022

Conversation

hschne
Copy link
Contributor

@hschne hschne commented Jan 28, 2022

First of all, let me say that I really love this gem, its super neat! 💯

I do have some trouble using it at the moment, however. When using sidekiq-statistic with Sidekiq 6.3 or later, it will be broken, as Sidekiq itself no longer ships with jQuery (see Changelog). This was also brought up in #180.

Reproducing

Add sidekiq 6.3 or later and sidekiq-statistic to your gem file. Open the Sidekiq UI, head to the Statistic tab and observe errors in the console. Functionality such as graphs, polling or date picker will not work.

Fix

First, because it was doable, realtime_statistic.js was moved off jQuery by replacing it with plain JS. If Sidekiq can do it, so can we! 😛

Unfortunately, doing the same for statistic.js was not really feasible, as that would mean adding a new date picker and so on, and that is kind of a big change. Instead, I opted for loading Sidekiq from a CDN only if Sidekiq 6.3 or later is used.

Let me know if you need any additional changes. I'd be happy to open any follow up PRs to also move statistic.js away from jQuery, if you have any ideas there 🙂

@wenderjean
Copy link
Collaborator

Sorry for the big delay and thanks for your contribution @hschne, I'll take a look and merge asap.

lib/sidekiq/statistic/views/statistic.erb Show resolved Hide resolved

const updateCharts = () => {
if (noVisibleWorkers()) {
return
}

requestJSON(Charts.paths.realtime, { data: { excluded: Data.excludedWorkers } })
.done(function (data) {
.then(response => response.json())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me we don't exactly need this line here and also the 74. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, could you go into more detail why not? I'm not able to follow.

updateCharts and initializeCharts are two distinct functions, both requesting distinct data. Both responses should arrive as JSON and thus would need to be converted, right? I feel like I may be missing something here 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind @hschne, I supposed the response to be json already, sorry.

@wenderjean
Copy link
Collaborator

Closes #180

@hschne
Copy link
Contributor Author

hschne commented Mar 25, 2022

Hey @wenderjean , sorry for the delay on my part, I took a bit of a longer vacation 🏖️

I think everything should be in order now. If you are planning to properly move the other files off JQuery too I'd be happy to lend a hand 🙂

Copy link
Collaborator

@wenderjean wenderjean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @hschne.

@wenderjean
Copy link
Collaborator

@hschne I created this other issue to track JQuery removal on statistic.js, fell free to leave it a comment and I can assign it to you.

@wenderjean wenderjean merged commit 446acb1 into davydovanton:master Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants